package com.kuiandjie.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import com.kuiandjie.entity.EmployeeTask;
import com.kuiandjie.util.DBHelp;
import com.kuiandjie.util.RowMapper;

public class EmpTaskDao {
	DBHelp<EmployeeTask> db = new DBHelp<EmployeeTask>();
	
	private class EmpTaskRowMapper implements RowMapper<EmployeeTask>{

		@Override
		public EmployeeTask mapperRow(ResultSet rs) throws SQLException {
			EmployeeTask emt = new EmployeeTask();
			emt.setEmpName(rs.getString("EmpName"));
			emt.setTaskId(rs.getInt("TaskId"));
			return emt;
		}
		
	}

	public List<EmployeeTask> getAll(String curgid) {
		String sql = "SELECT t_employee.name AS EmpName,t_task.id AS TaskId from t_employee,t_task WHERE t_employee.id = t_task.t_employee_id and t_goal_id = ?";
		return db.executeQueryForList(sql, new EmpTaskRowMapper(), curgid);	
	}

}
